IB_INCS=/usr/local/include/embedded_innodb-1.0/
IB_LIBS=-L/usr/local/lib -linnodb
READLINE=-ledit
#READLINE=-lreadline
EXTRA_LIBS=-lpthread -lcurses
LINKENV=LD_RUN_PATH=/usr/local/lib

INCLUDES=-I$(IB_INCS)

CXXFLAGS=-g -Wall $(INCLUDES)
CFLAGS=-g -Wall $(INCLUDES)

OBJECTS=Parser.o Scanner.o SQLnode.o SQLtable.o Variable.o \
describe.o utilities.o

all: ddltool

ddltool: Parser.cpp main.o $(OBJECTS) 
	$(LINKENV) $(CXX) -Wall -o $@ main.o $(OBJECTS) $(IB_LIBS) $(READLINE) $(EXTRA_LIBS)

main.o: main.cpp
Parser.o: Parser.cpp
Scanner.o: Scanner.cpp
SQLnode.o: SQLnode.cpp SQLnode.h errors.map
SQLtable.o: SQLtable.cpp SQLnode.h errors.map
Variable.o: Variable.cpp SQLnode.h Variable.h
describe.o: describe.c
utilities.o: utilities.cpp

Parser.cpp: SQLnode.h SQL.atg
	Coco -frames ./frames SQL.atg

clean:
	rm -f *.o Parser.cpp

tests:
	awk -f test-runner.awk test.list | bash
